<!--
 * @Descripttion: 
 * @version: 
 * @Author: siebe
 * @Date: 2022-02-18 00:23:39
 * @LastEditors: siebe
 * @LastEditTime: 2022-02-21 03:05:45
-->
{include file="public/header" /}
    <div class="header">
        <span>导航列表</span>
        <button type="button" class="layui-btn layui-btn-sm" onclick="add()">
            <i class="layui-icon layui-icon-add-1"></i>添加
        </button>
        <div></div>
    </div>
    <table class="layui-table">
        <thead>
            <tr>
                <th>ID</th>
                <th>菜单名</th>
                <th>排序</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {volist name="lists" id="vo"}
            <tr>
                <td>{$vo.id}</td>
                <td><i class="layui-icon {$vo.icon}"></i> {$vo.name}</td>
                <td>{$vo.sort}</td>
                <td>
                    {if ($vo.status == 1) }
                    开启
                    {else /}
                    关闭
                    {/if}
                </td>
                <td>
                   
                        <button type="button" class="layui-btn layui-btn-sm layui-btn-warm" onclick="next({$vo.id})">
                            <i class="layui-icon">&#xe602;</i>下一级
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="edit({$vo.id})">
                            <i class="layui-icon">&#xe642;</i>编辑
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="del({$vo.id})">
                            <i class="layui-icon">&#xe640;</i>删除
                        </button>
                    
                </td>
            </tr>
            {/volist}
        </tbody>
    </table>
    <script type="text/javascript">
        layui.use(['layer'], function () {
            $ = layui.jquery;
        })
        function add() {
            layer.open({
                type: 2,
                title: '添加导航',
                shade: 0.3,
                area: ['550px', '400px'],
                content: '{$config.path}navigation/add'
            })
        }
        function edit(id) {
            layer.open({
                type: 2,
                title: '修改导航',
                shade: 0.3,
                area: ['550px', '400px'],
                content: '{$config.path}navigation/edit?id=' + id
            })
        }
        function del(id) {
            layer.confirm('您确定要删除吗？', {
                icon: 3,
                btn: ['确定', '取消']
            }, function () {
                $.get('{$config.path}navigation/delete?id=' + id, function (res) {
                    if (res.error_code == 0) {
                        layer.msg(res.msg, { 'icon': 1 });
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    } else {
                        layer.msg(res.msg, { 'icon': 2 });
                    }
                }, 'json').error(function (res) {
                    layer.msg(res.responseJSON.msg, { 'icon': 2 });
                });
            })
        }
        function next(id) {
            window.location.href = "{$config.path}menu/index?pid=" + id
        }
    </script>
</body>

</html>